package com.zretc.controller;

import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.HandlerInterceptor;

@Controller
public class TestModelController {

	/**
	 * Model 接口
	 * @param model
	 * @return
	 */
	
	@GetMapping("model01")
	public String  model01(Model model,ModelMap modelMap,Map map)
	{
		
		//HandlerInterceptor
		
		//提高题
		//model.addAttribute(arg0);//这个方法有啥区别
		//model.addAttribute(arg0, arg1);//这个方法
		model.addAttribute("name1", "tom");//这个方法		
		modelMap.addAttribute("name2", "jerry");
		map.put("name3", "佩琪");		
		System.out.println(model == modelMap);
		System.out.println(model == map);
		return "forward:model01.jsp";
	}
	
	//@RequestMapping(value= "req01",method = RequestMethod.GET) 等价于 @GetMapping("req01")
	@RequestMapping(value= "req01",method = RequestMethod.GET)
	public String  req01()
	{
		//提高题
		//model.addAttribute(arg0);//这个方法有啥区别
		//model.addAttribute(arg0, arg1);//这个方法
		System.out.println("req01");
		return "string";
	}
}
